public class Solution2283 {
    public boolean digitCount(String num) {
        int[] f=new int[10];
        for (char c : num.toCharArray()) {
            f[c-'0']++;
        }
        for (int i=0;i<num.length();i++){
            if (f[i]!=num.charAt(i)-'0'){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution2283().digitCount("1210"));
    }
}
